//@author A0102103L
//
// **********
//
// display class receives the entire store from 
// logic, and sieves out the tasks that
// user wishes to see
//
// **********

#include "Display.h"

Display::Display(void) {

}

Display::~Display(void) {

}

vector <Task> Display::execute(vector<Task> store) {
	return store;
}

vector <Task> Display::execute(string command, vector<Task> store) {
	vector<Task> output;

	// default shows all but archive
	if(command == DEFAULT) {
		for(vector<Task>::iterator iter = store.begin(); iter != store.end(); iter++) {
			if((*iter).getStatus() != ARCHIVE) {
				output.push_back(*iter);
			}
		}
    // shows all including archive
	} else if(command == ALL) {
		return store;
    // shows only the specified priority
	} else if(command == HIGH || command == MEDIUM || command == LOW) {
		for(vector<Task>::iterator iter = store.begin(); iter != store.end(); iter++) {
			if((*iter).getPriority() == command) {
				output.push_back(*iter);
			}
		}
    // shows only the specified status
	} else if(command == CMI || command == WIP || command == DONE || command == ARCHIVE || command == WORK_IN_PROGRESS) {
		if(command == WORK_IN_PROGRESS) {
				command = WIP;
		}

		for(vector<Task>::iterator iter = store.begin(); iter != store.end(); iter++) {
			if((*iter).getStatus() == command) {
				output.push_back(*iter);
			}
		}

	} else {
		throw exception("display type error");
	}
	return output;
}